<template>
  <div class="index">
    <viewer @on-viewer-completed='viewerCompletedHandler'></viewer>
    <!-- 组件加载完毕后执行下面的组件构建方法 -->
    <template v-if="loaded">
      <control></control>
    </template>
  </div>
</template>

<script>
import ViewerApi from '@/api/ViewerApi'
import Control from '../components/Control/index.vue'

export default {
  name: 'Index',
  data() {
    return {
      loaded: false
    }
  },
  components: { Control },
  methods: {
    viewerCompletedHandler(viewer) {
      window.mapApi = new ViewerApi(viewer)
      mapApi.addBaseLayer()
      this.loaded = true
    }
  }
}
</script>

<style lang='scss' scoped>
.index {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
</style>
